# -*- coding:utf-8 -*-

import random

class TitleCluster():
    def __init__(self, vectorizer, paperidx_text_dict, paperidx_list ):
        self.paperidx_text_dict = paperidx_text_dict
        self.paperidx_list = paperidx_list

        self.cluster_idx_text_dict = self._get_cluster_idx_text_dict()
        self.cluster_text = self._get_cluster_text()

        self.text_vec = vectorizer.transform([ self.cluster_text ] ).toarray()[0]


    def _get_cluster_idx_text_dict(self):
        cluster_idx_text_dict = {}
        for idx in self.paperidx_list:
            text = self.paperidx_text_dict[idx]
            cluster_idx_text_dict[idx] = text

        return cluster_idx_text_dict

    def _get_cluster_text(self):
        sum_text = [ ]
        for text in self.cluster_idx_text_dict.values():
            sum_text.append( str(text) )
        return ' '.join(sum_text).strip()

    def _get_random_idx(self):
        idx = random.randint(0, len(self.paperidx_list)-1)
        return self.paperidx_list[idx]

"""
 得到 clean title
 
 需要 单独 得到 VSM 词袋 对象  
 词袋 和 tfidf
 
 然后 将 title 连接在 一块 传至 vsm 词袋对象 
 
 得到向量
 
 构造函数， 在多一 参数
"""


